import { Component, OnInit } from '@angular/core';

import { Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
var base=require('modules/base.js');
@Component({
  selector: 'app-read',
  templateUrl: './read.component.html',
  styleUrls: ['./read.component.less']
})
export class ReadComponent implements OnInit {
	lists=[];
	policy() {
//	this.$router.push({ name:'policy',path: '/policy' ,params:{lists:this.lists}});
	};
  constructor(private http: Http) { 
  	window['read']=this;
  	var that = this;
  	var sessionStorage=window['sessionStorage'];
		base.request(base.api(57), {}, function (data) {
			if (data.data.length > 0) {
				var _iteratorNormalCompletion = true;
				var _didIteratorError = false;
				var _iteratorError = undefined;

				try {
					for (var _iterator = data.data[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
						var value = _step.value;
						console.log(value.id)
						base.request(base.api(58), { id: value.id }, function (d) {
							if (d.data) {
								value.content = d.data.content;
								that.lists.push(value);
								sessionStorage.setItem('gk',JSON.stringify(that.lists))
							}
						});
					}
				} catch (err) {
					_didIteratorError = true;
					_iteratorError = err;
				} finally {
					try {
						if (!_iteratorNormalCompletion && _iterator.return) {
							_iterator.return();
						}
					} finally {
						if (_didIteratorError) {
							throw _iteratorError;
						}
					}
				}
			}
		});
  }

  ngOnInit() {
  }

}
